<!doctype html>
<html lang="en">
{include file='public/header'}
<body class="login-bg">
    <div class="login layui-anim layui-anim-up">
        <div class="message">小视频-管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        </form>
    </div>

    <script>
        $(function () {
            layui.use('form', function(){
                var form = layui.form;
                form.on('submit(login)', function(data){
                    Ajax('/admin/login/login', data.field).then(data => {
                        data.data['token_time'] = new Date().getTime()
                        localStorage.setItem('adminToken',data.data.token)
                        localStorage.setItem('adminMessage',JSON.stringify(data.data))
                        if (data.code===200) {
                            layer.msg('登录成功!',{icon:1,time:1500},function () {
                                jumpUrl('/admin/index/index?token='+data.data.token,true)
                            });
                            return false;
                        }
                    });
                    return false;
                });
             });
        });
        function reg() {
            jumpUrl('{:url("admin/login/reg")}')
        } 
    </script>

</body>
</html>